<?php
namespace app\common\model;

class LiveChat extends Common
{
    protected $autoWriteTimestamp = true;
    protected $createTime = 'ctime';
    /**
     * 获取聊天列表
     */
    public function chatList($data){
        $list=$this->alias('a')
            ->where(['room_id'=>$data['room_id'],'live_id'=>$data['live_id']])
            ->join('zp_user u','u.id=a.uid','left')
            ->field('a.*,u.nickname,u.avatar')
            ->page($data['page'],$data['limit'])
            ->order('a.id asc')
            ->select();
        return $list;
    }
    /**
     * 提交聊天
     */
    public function addChat($data){
        $res=$this->create($data);
        if(!$res){
            return [false,'error'];
        }
        return [true,'success'];
    }
}
